<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>登录 - 智慧粮库测控平台</title>
    <link rel="stylesheet" href="../css/theme.css">
    <link rel="stylesheet" href="../css/common.css">
    <link rel="stylesheet" href="../css/login.css">
    <link rel="stylesheet" href="../css/iconfont.css">
    <link rel="stylesheet" href="../layui-v2.8.17/layui/css/layui.css">
    <style>
        .login-tips {
            margin-top: 15px;
            padding: 10px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            font-size: 14px;
            color: rgba(255, 255, 255, 0.8);
        }
        .login-tips p {
            margin: 5px 0;
        }
    </style>
</head>
<body id="theme-body">
    <div class="login-container">
        <div class="login-content">
            <div class="login-header">
                <div class="logo-container">
                    <img src="../image/logo.png" alt="logo" class="login-logo" />
                    <h1>华荣安工智慧粮库</h1>
                </div>
            </div>
            
            <div class="login-form">
                <div class="form-title">账号登录</div>
                
                <div id="error-message" class="error-message"></div>
                
                <div class="input-group">
                    <i class="layui-icon layui-icon-username"></i>
                    <input type="text" id="username" placeholder="用户名" class="login-input">
                </div>
                
                <div class="input-group">
                    <i class="layui-icon layui-icon-password"></i>
                    <input type="password" id="password" placeholder="密码" class="login-input">
                    <i class="layui-icon layui-icon-eye password-toggle" id="password-toggle"></i>
                </div>
                
                <div class="login-options">
                    <label class="checkbox-container">
                        <input type="checkbox" id="remember-me">
                        <span class="checkmark"></span>
                        <span class="checkbox-text">记住我</span>
                    </label>
                    
                    <a href="#" class="forgot-password" style="display: none;">忘记密码?</a>
                </div>
                
                <button id="login-btn" class="login-btn">登录</button>
                
                <div class="login-tips" style="display: none;">
                    <p>操作员账号: admin / admin</p>
                    <p>观察员账号: viewer / viewer</p>
                    <p>操作员可以控制设备，观察员只能查看数据</p>
                </div>
                
                <div class="login-footer">
                    <p id="copyright-info"></p>
                </div>
            </div>
        </div>
        
        <div class="login-decoration">
            <div class="decoration-item" style="--delay: 0s"></div>
            <div class="decoration-item" style="--delay: 2s"></div>
            <div class="decoration-item" style="--delay: 4s"></div>
        </div>
    </div>
    
    <!-- VConsole 调试工具 -->
    <script src="../lib/vconsole/vconsole.min.js"></script>
    <script src="../js/vconsole-init.js"></script>
    <!-- 通用工具库 -->
    <script src="../lib/jquery.js"></script>
    <script src="../js/android-interface.js"></script>
    <script src="../js/common.js"></script>
    <script src="../js/permissions.js"></script>
    <script src="../js/widgets.js"></script>
    <!-- 用户管理 -->
    <script src="../js/usermanager.js"></script>
    <!-- 模拟数据 -->
    <script src="../js/mock/mock-user-data.js"></script>
    <!-- 登录脚本 -->
    <script src="../js/login.js"></script>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // 加载保存的主题
            if (typeof loadSavedTheme === 'function') {
                loadSavedTheme();
            }
            
            // 初始化登录页面
            initLoginPage();
            
            // 密码显示/隐藏切换
            const passwordToggle = document.getElementById('password-toggle');
            const passwordInput = document.getElementById('password');
            
            if (passwordToggle && passwordInput) {
                // 确保密码输入框可点击
                passwordInput.addEventListener('click', function(e) {
                    e.stopPropagation();
                    this.focus();
                });
                
                // 确保密码图标只处理自己的点击事件
                passwordToggle.addEventListener('click', function(e) {
                    e.stopPropagation();
                    if (passwordInput.type === 'password') {
                        passwordInput.type = 'text';
                        passwordToggle.classList.remove('layui-icon-eye');
                        passwordToggle.classList.add('layui-icon-eye-invisible');
                    } else {
                        passwordInput.type = 'password';
                        passwordToggle.classList.remove('layui-icon-eye-invisible');
                        passwordToggle.classList.add('layui-icon-eye');
                    }
                });
            }
            // 设置底部版权信息
            var version = (window.AppConfig && window.AppConfig.version) ? window.AppConfig.version : '';
            var copyright = `© 2024-2030 智慧粮库系统 版本 ${version}`;
            var copyrightEl = document.getElementById('copyright-info');
            if (copyrightEl) copyrightEl.textContent = copyright;
        });
    </script>
</body>
</html>
